﻿@model BookViewModel

<div class="bookContentContainer clearFix">
	@if ((bool)Session["isAdmin"])
	{
		<div class="commandBar bookCommandBar">
			<a href="#top"><span class="icon addIcon mediumIcon" data-tooltip-url="@Url.Action("GetGenericTooltip", "Tooltip")" data-tooltip-type="@((int)TooltipType.Add)" data-tooltip-id="genericTooltip">&nbsp;</span></a>
			<a href="#top"><span class="icon editIcon mediumIcon" data-tooltip-url="@Url.Action("GetGenericTooltip", "Tooltip")" data-tooltip-type="@((int)TooltipType.Edit)" data-tooltip-id="genericTooltip">&nbsp;</span></a>
			<a><span class="icon deleteIcon mediumIcon" data-tooltip-url="@Url.Action("GetGenericTooltip", "Tooltip")" data-tooltip-type="@((int)TooltipType.Delete)" data-tooltip-id="genericTooltip">&nbsp;</span></a>
		</div>
	}
	<div class="bookContent clearFix">
		@using (Html.BeginForm("DeleteBook", "Library", FormMethod.Post, new { name="bookDeleteForm"}))
		{
			<input name="bookID" type="hidden" value="@Model.ID"/>
		}
		<div class="bookInfo">
			<div class="defaultHeaderFont bookTitle">
				<span class="title">@Model.BookTitle</span> 
				<span class="lighter">by
					<span class="author">@Model.Authors</span>
				</span>
			</div>
			<div class="bookDescriptionContainer">
				<div class="bookDescription">
					<pre class="formattedDescription defaultMainFont">@Model.Description</pre>
				</div>
			</div>
			<div class="bookFooter clearFix">
					@Html.Partial("BookDetails", Model.Details)
				<div class="ownerContainer">
					<div class="owner">
						<span class="ownerTitle">Owner:</span>
						<span class="ownerText">
							@if (!string.IsNullOrEmpty(Model.OwnerName))
							{
								<span class="peopleName" data-tooltip-url="@Url.Action("GetPersonInfoTooltip", "Tooltip")" data-person-id="@Model.OwnerID" data-tooltip-id="personInfoTooltip">@Model.OwnerName</span>
							}
							else
							{
								@:Library
							}
						</span>
					</div>
				</div>
			</div>
		</div>
		<div class="bookCoverContainer">
				@{
					string coverUrl = string.Empty;
					bool isEANAvailable = !string.IsNullOrEmpty(Model.EAN);
					bool isISBNAvailable = !string.IsNullOrEmpty(Model.ISBN);
				}

			<div class="@(isEANAvailable || isISBNAvailable ? "coverRef previewCover" : "coverRef")">
				
				@if (!string.IsNullOrEmpty(Model.Image.Uri))
				{
					coverUrl = Model.Image.Uri;
				}
				else if (!string.IsNullOrEmpty(Model.Image.ID))
				{
					coverUrl = Url.Action("GetImage", "Image", new { ID = Model.Image.ID });
				}
				else
				{
					coverUrl = @Url.Content("~/Content/Images/book_cover_not_available.png");
				}
				
				<img class="bookCover" src="@coverUrl" alt="Book's cover" />

				@if (isEANAvailable || isISBNAvailable)
				{
					<span class="previewLabel">Preview</span>
				}
			</div>
			@if (isISBNAvailable)
			{
				<div class="boxIDContainer">
					<span class="labelID">ISBN:</span>
					<span class="bookISBN">@Model.ISBN</span>
				</div>
			}
			@if (isEANAvailable)
			{
				<div class="boxIDContainer">
					<span class="labelID">EAN:</span>
					<span class="bookEAN">@Model.EAN</span>
				</div>
			}
		</div>
	</div>
</div>
